package me.chan.nio.channel;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

@Slf4j
public class Client {

    public static void main(String[] args) {

        SocketChannel socket;
        try {
            socket = SocketChannel.open();
            socket.connect(new InetSocketAddress("127.0.0.1", 8080));
            log.info("waiting for subsequent operation...");
            socket.write(StandardCharsets.UTF_8.encode("abcdefgh\nxywzhhi\n"));
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
